package com.glsc.ngateway.common.base.repo.mysql.gateway.platform.flow.cmdb;


import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormDeviceStandardModify;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author liwei
 */
@Repository
public interface FlowFormDeviceStandardModifyRepo extends JpaRepository<FlowFormDeviceStandardModify, Long>, JpaSpecificationExecutor<FlowFormDeviceStandardModify> {
    /**
     * 根据流程Id检索表单
     */
    FlowFormDeviceStandardModify findByProcessId(String processId);

    List<FlowFormDeviceStandardModify> findAllByProcessId(String processId);

    @Query(value = "select distinct i.* from t_gw_flow_form_device_standard_new_detail d" +
            " left join t_gw_flow_form_device_standard_modify i on d.process_id = i.process_id  where i.is_close = 0 and i.modify_type = 0 and d.standard_name = :standardName  ", nativeQuery = true)
    List<FlowFormDeviceStandardModify> findFlowDeviceStandardName(String standardName);
}
